<template>
  <div></div>
</template>

<script>
import EvenEmitter from '../../utils/evenEmitter'
import NewPromise from '../../utils/newPromise'
export default {
  mounted () {
    this.studyEven()
    this.studyPromise()
  },
  methods: {
    studyEven () {
      const emitter = new EvenEmitter()
      // function hello1 (name) {
      //   console.log('hello 1', name)
      // }
      // function hello2 (name) {
      //   console.log('hello 2', name)
      // }
      // function hello3 (name) {
      //   console.log('只打印一次', name)
      // }
      // emitter.on('han', hello1)
      // emitter.addListener('han', hello2)
      // emitter.once('han', hello3)
      // emitter.emit('han', '通湃')
      // console.log('emitter', emitter)
    },
    studyPromise () {
      const promise = new NewPromise((resolve, reject) => {
        setTimeout(() => {
          reject(1)
          // resolve(1)
        }, 1)
      }).then((data) => {
        console.log('成功', data)

      }).then(undefined, (e) => {
        console.log('失败', e)
      })
    }
  }
}
</script>

<style scoped>
</style>
